package CCN::modules::core_bootstrap;
# Copyright (C) 2006, 2007  Stephane Alnet
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 3
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
use strict; use warnings;

use base qw(CCN::Core::Module);

sub _description
{
    return {
        name        => 'core_bootstrap',
        title       => 'Bootstrap',
        description => 'This module provides Bootstrapping for CarrierClass.net.',
        group       => 'Core',
        version     => '0.1',
        requires    => [],
        operations  =>
            {
                install =>
                {
                    do => sub
                    {
                        # Part 1: make sure we should be running.
                        if( defined CCN::Core::Configuration::get('bootstrapped') )
                        {
                            if( defined $ARGV[0] and $ARGV[0] eq '-f' )
                            {
                                print STDERR "CCN-WARNING: Forcing bootstrap as requested.\n";
                                CCN::Core::Configuration::set('bootstrapped',undef);
                            }
                            else
                            {
                                print STDERR "CCN-ERROR: This system was previously bootstrapped";
                                return 0;
                            }
                        }
                        
                        # Part 2: execute any bootstrap hooks
                    }
                },
            },
    }
}

1;